function eVector=eVlstar(gamma,y,x,q,c)

T=size(y,1);
N=size(y,2);

fX  = 1./(1+exp(-exp(gamma)/std(q)*(q-c)));

rec = 1-fX;

betas=[];
e=[];
for i=1:N;
    
    y_i=y(:,i);
    
    x_i=[ones(T,1) x(:,i)];

    x_i=[x_i.*(rec*ones(1,2)) x_i.*(1-(rec(:,1)*ones(1,2)))];
        
    betas_i=x_i\y_i;
    
    betas=[ betas; betas_i ];
    
    e_i=y_i-x_i*betas_i;
    e=[ e e_i ];
    
end

eVector=reshape(e,[T*N,1]);

end